package com.cswangdao.result;

import com.github.pagehelper.Page;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class PageResult<T> {

   private Integer limit;
   private List<T> list;
   private Integer page;
   private Integer pages;
   private Long total;

   public static <T> PageResult<T> result(Page<T> pageObject) {
      return new PageResult<>(pageObject.getPageSize(),
              pageObject.getResult()
              , pageObject.getPageNum()
              , pageObject.getPages()
              , pageObject.getTotal());

   }
}
